#ifndef ENTITY_H
#define ENTITY_H

#include "GlobalData.h"
#include "GlobalFunctions.h"
#include "PhysicalBody.h"
#include <list>

class Entity{

public:
	Entity();	//constructor
	~Entity();	//destructor

	//pure virtual functions
	//these need to be implemented by children
	virtual bool Initialize(unsigned int entity_number = 0);	//initialization routine
	virtual bool Update();			//on-frame-update routine
	virtual void Blit();
	virtual bool Deinitialize();	//deinitialization routine

	virtual PhysicalBody* GetBody();	//pure virtual, this should never be called on Entity

	bool CollideWith(Entity* b);

	virtual void SetX(int x);
	virtual void SetY(int y);
	virtual void SetW(int w);
	virtual void SetH(int h);
	virtual void SetVX(float vx);
	virtual void SetVY(float vy);
	virtual void SetAX(float ax);
	virtual void SetAY(float ay);

	virtual int GetX();
	virtual int GetY();
	virtual int GetW();
	virtual int GetH();	
	
	virtual float GetVX();
	virtual float GetVY();
	virtual float GetAX();
	virtual float GetAY();

	virtual void ApplyForce(float x = 0, float y = 0);
	
	virtual void SetChanged(bool changed);	//let others know this entity has been updated
	virtual bool HasChanged();	//entity has been changed recently
	bool changed; //this entity has been updated
	unsigned int GetType();

	static void AddToEntityList(Entity* entity);	//create a new entity and push it to the list
	static unsigned int GetEntityCount();	//get the number of entities in the list (world)
	static Entity* GetEntity(int number);	//find the entity based on its index in the list
	static void UpdateAllEntities();		//update all entities in the list (world)

	int SetLife(int life);
	int GetLife();

protected:
	PhysicalBody body;			//collision box
	unsigned int type;			//the entity type
    static std::list<Entity*>	entityList;	//list of all entities in the world
	FUNCTIONAL_STATE state;	//state of the entity
	unsigned int life;

};

#endif